package com.kolaxy.hytrix;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DcController {

    @Autowired
    ConsumerService consumerService;

    @GetMapping(value = "/consumer")
    public String dc() {

        return consumerService.consumer();

    }

    @Component
    class ConsumerService {
        @Autowired
        DcClient dcClient;

        @HystrixCommand(fallbackMethod = "fallback")
        public String consumer() {
            return dcClient.consumer();
        }

        public String fallback() {
            return "fallback";
        }
    }

}
